//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using System.Windows;

namespace OpenLS.UI
{
    /// <summary>
    /// Exposes the resources keys used for the brushes common to all Office applications
    /// </summary>
    public static class OfficeBrushes
    {
        private static bool initialized;

        public static ResourceKey RibbonBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonBorderBrush); }
        }

        public static ResourceKey ScrollBarBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ScrollBarBackground); }
        }

        public static ResourceKey RibbonCheckBoxBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonCheckBoxBackground); }
        }

        public static ResourceKey RibbonCheckBoxBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonCheckBoxBorderBrush); }
        }

        public static ResourceKey RibbonComboBoxBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonComboBoxBackground); }
        }

        public static ResourceKey RibbonComboBoxBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonComboBoxBorderBrush); }
        }

        public static ResourceKey RibbonBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonBackground); }
        }

        public static ResourceKey ScrollBarVerticalRepeatButtonPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.PressedBrushV); }
        }

        public static ResourceKey ScrollBarThumbGlyphBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ScrollBarThumbGlyphBrush); }
        }

        public static ResourceKey ScrollBarHorizontalThumbHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ScrollBarThumbHoverBackground); }
        }

        public static ResourceKey ScrollBarDisabledForegroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.DisabledForegroundBrush); }
        }

        public static ResourceKey ScrollBarVerticalThumbHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.HoverBrushV); }
        }

        public static ResourceKey ScrollBarThumbBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.NormalBrushH); }
        }

        public static ResourceKey ScrollBarVerticalThumbBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.NormalBrushV); }
        }

        public static ResourceKey ScrollBarRepeatButtonBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ScrollBarNormalRepeatButtonBrush); }
        }

        public static ResourceKey ScrollBarRepeatButtonGlyphBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GlyphBrush); }
        }


        public static ResourceKey GalleryItemSelectedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GalleryItemSelectedBackground); }
        }

        public static ResourceKey RibbonContentBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.RibbonContentBackground); }
        }

        //d4e6f8
        public static ResourceKey GalleryHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GalleryHoverBackground); }
        }

        public static ResourceKey GalleryBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GalleryBackground); }
        }

        public static ResourceKey ResizeThumbBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ResizeThumbBackground); }
        }

        public static ResourceKey ResizeThumbBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ResizeThumbBorderBrush); }
        }

        public static ResourceKey GalleryItemHoverSelectedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GalleryItemHoverSelectedBackground); }
        }

        public static ResourceKey ZoomTickBarForegroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ZoomTickBarForeground); }
        }

        public static ResourceKey TooltipBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.TooltipBackground); }
        }

        public static ResourceKey StatusBarBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.StatusBarBackground); }
        }

        public static ResourceKey QuickAccessToolbarBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.QuickAccessToolbarBorderBrush); }
        }

        public static ResourceKey ZoomBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ZoomBackground); }
        }

        public static ResourceKey ApplicationMenuButtonBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuButtonBackground); }
        }

        public static ResourceKey ApplicationMenuButtonPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuButtonPressedBackground); }
        }

        public static ResourceKey ApplicationMenuButtonHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuButtonHoverBackground); }
        }

        public static ResourceKey MenuHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuHoverBackground); }
        }

        public static ResourceKey MenuHoverBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuHoverBorderBrush); }
        }

        public static ResourceKey MenuHover2BackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuHover2Background); }
        }

        public static ResourceKey MenuPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuPressedBackground); }
        }

        public static ResourceKey MenuArrowHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuArrowHoverBackground); }
        }

        public static ResourceKey MenuArrowHover2BackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuArrowHover2Background); }
        }

        public static ResourceKey MenuArrowPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuArrowPressedBackground); }
        }

        public static ResourceKey ButtonHoverSelectedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ButtonHoverSelectedBackground); }
        }

        public static ResourceKey ButtonPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ButtonPressedBackground); }
        }

        public static ResourceKey TextForegroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.TextForeground); }
        }

        public static ResourceKey ButtonHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ButtonHoverBackground); }
        }

        public static ResourceKey ComboBoxHoverBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ComboBoxHoverBorderBrush); }
        }

        public static ResourceKey ApplicationMenuOuterBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuOuterBorderBrush); }
        }

        public static ResourceKey GroupBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupBorderBrush); }
        }

        public static ResourceKey ApplicationMenuFooterButtonBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuFooterButtonBackground); }
        }

        public static ResourceKey ApplicationMenuInnerBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuInnerBorderBrush); }
        }

        public static ResourceKey ApplicationMenuFooterButtonPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuFooterButtonPressedBackground); }
        }

        public static ResourceKey ButtonSelectedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ButtonSelectedBackground); }
        }

        public static ResourceKey ComboBoxArrowHoverBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ComboBoxArrowHoverBorderBrush); }
        }

        public static ResourceKey GroupContentBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupContentBackground); }
        }

        public static ResourceKey GroupHeaderBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupHeaderBackground); }
        }

        public static ResourceKey ComboBoxHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ComboBoxHoverBackground); }
        }

        public static ResourceKey ApplicationMenuFooterBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuFooterBackground); }
        }

        public static ResourceKey GroupContentPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupContentPressedBackground); }
        }

        public static ResourceKey GroupHeaderPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupHeaderPressedBackground); }
        }

        public static ResourceKey MenuDownBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.MenuDownBackground); }
        }

        public static ResourceKey TabItemHighlightedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.HighlightedTabItemBackground); }
        }

        public static ResourceKey ApplicationMenuRightPaneBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuRightPaneBackground); }
        }

        public static ResourceKey GroupContentHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupContentHoverBackground); }
        }

        public static ResourceKey GroupHeaderHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.GroupHeaderHoverBackground); }
        }

        public static ResourceKey ComboBoxArrowHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ComboBoxArrowHoverBackground); }
        }

        public static ResourceKey ComboBoxPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ComboBoxPressedBackground); }
        }

        public static ResourceKey ComboBoxPressedBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ComboBoxPressedBorderBrush); }
        }

        public static ResourceKey NormalBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.NormalBorderBrush); }
        }

        public static ResourceKey TabItemSelectedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.SelectedTabItemBackground); }
        }

        public static ResourceKey ZoomNormalBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ZoomNormalBackground); }
        }

        public static ResourceKey MenuHighlightedHoverBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.HighlightedMenuHoverBackground); }
        }

        public static ResourceKey ScrollBarHorizontalRepeatButtonPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ButtonPressed2Background); }
        }

        public static ResourceKey ZoomNormalBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ZoomNormalBorderBrush); }
        }

        public static ResourceKey ZoomDarkBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ZoomDarkBackground); }
        }

        public static ResourceKey BoxBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.BoxBackground); }
        }

        public static ResourceKey BoxBorderBrushKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.BoxBorderBrush); }
        }

        public static ResourceKey TabItemBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.TabItemBackground); }
        }

        public static ResourceKey ApplicationMenuPressedBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ApplicationMenuPressedBackground); }
        }

        public static ResourceKey ZoomDisabledBackgroundKey
        {
            get { return GetOfficeUIResourceKey(OfficeUIResourceId.ZoomDisabledBackground); }
        }

        private static ResourceKey GetOfficeUIResourceKey(OfficeUIResourceId id)
        {
            var result = new OfficeUIResourceKey(id);
            ;
            if (!initialized)
            {
                initialized = true;
                Application app = Application.Current;
                if (app != null)
                {
                    IEnumerable<ResourceDictionary> dictionaries;
                    {
                        dictionaries = app.Resources.MergedDictionaries;

                        foreach (ResourceDictionary dictionary in dictionaries)
                        {
                            if (dictionary.GetType().GetCustomAttributes(typeof (OfficeSkinAttribute), true).Length > 0)
                                return result;
                        }
                    }
                    app.Resources.MergedDictionaries.Add(new Office2007BlueSkin());
                }
            }
            return result;
        }
    }
}